﻿<?php 
    //创建memcache对象
    $mem = new Memcached();
 
    //连接memcache服务器
    $mem -> addServer("localhost", 11211);
	
 
	// 定义数据
	$bus_list = Array( 
					"0358911020137762",
					"0358911020148140",
					"0358911020137754",
					"0358911020137739",
					"0358911020137747",
					"0358911020137721",
					"0358511020493213",
					"0865067022454725",
					"0358511020493759",
					"0358511020493189",
					"0358511020493171",
					"0358911020122939",
					"0358511020493429",
					"0358511020493239",
					"0358511020493254",
					"0123456789012345",
					"0358511020493221",
					"1234567890123456",
					"0355784011560745",
					"0355784011561420",
					"03557840115614",
					"0102030405060708", 
					);
	print_r($bus_list);
	$data1 = Array( 
					"company" => "沈阳航空航天大学",
					"route_num" => 13,
					"plate_num" => "辽SAU001",
					"longitude" => 12745.1307,
					"latitude" => 423.25709999,
					"imei" => "0358911020137762",
					"workerman_id" => "7f0000010fa30000003f",
					"x" => 127.01256030186,
					"y" => 42.00820186311,
					);
	$data2 = Array( 
					"company" => "沈阳航空航天大学" ,
					"route_num" => 11 ,
					"plate_num" => "辽A6387A" ,
					"longitude" => 12745.1307,
					"latitude" => 423.25709999,
					"imei" => "0358911020137754",
					"workerman_id" => "7f0000010fa300000024",
					"x" => 127.01256030186,
					"y" => 42.00820186311,
					);
	$data3 = Array( 
					"company" => "沈阳航空航天大学" ,
					"route_num" => 11 ,
					"plate_num" => "辽A6387A" ,
					"longitude" => 12745.1307,
					"latitude" => 423.25709999,
					"imei" => "0358911020137739",
					
					"workerman_id" => "7f0000010fa300010024" ,
					"x" => 127.01256030186,
					"y" => 42.00820186311,
					);
	$data4 = Array( 
					"company" => "沈阳航空航天大学" ,
					"route_num" => 11 ,
					"plate_num" => "辽A6387A" ,
					"longitude" => 12745.1307,
					"latitude" => 423.25709999,
					"imei" => "0358911020137747",
					
					"workerman_id" => "7f0000010fa300200024" ,
					"x" => 127.01256030186,
					"y" => 42.00820186311,
					);
	$data5 = Array( 
					"company" => "沈阳航空航天大学" ,
					"route_num" => 11 ,
					"plate_num" => "辽A6387A" ,
					"longitude" => 12745.1307,
					"latitude" => 423.25709999,
					"imei" => "0358911020137721",
					
					"workerman_id" => "7f0000010fa300300024",
					"x" => 127.01256030186,
					"y" => 42.00820186311,					
					);
	$data6 = Array( 
					"company" => "沈阳航空航天大学" ,
					"route_num" => 11 ,
					"plate_num" => "辽A6387A" ,
					"longitude" => 12745.1307,
					"latitude" => 423.25709999,
					"imei" => "0358511020493213",
					
					"workerman_id" => "7f0000010fa300500024" ,
					"x" => 127.01256030186,
					"y" => 42.00820186311,
					);
	$data7 = Array( 
					"company" => "沈阳航空航天大学" ,
					"route_num" => 11 ,
					"plate_num" => "辽A6387A" ,
					"longitude" => 12745.1307,
					"latitude" => 423.25709999,
					"imei" => "0865067022454725",
					
					"workerman_id" => "7f0000010fa300600024" ,
					"x" => 127.01256030186,
					"y" => 42.00820186311,
					);
	$data8 = Array( 
					"company" => "沈阳航空航天大学" ,
					"route_num" => 11 ,
					"plate_num" => "辽A6387A" ,
					"longitude" => 12745.1307,
					"latitude" => 423.25709999,
					"imei" => "0358511020493759",
					
					"workerman_id" => "7f0000010fa307000024" ,
					"x" => 127.01256030186,
					"y" => 42.00820186311,
					);
	$data9 = Array( 
					"company" => "沈阳航空航天大学" ,
					"route_num" => 11 ,
					"plate_num" => "辽A6387A" ,
					"longitude" => 12745.1307,
					"latitude" => 423.25709999,
					"imei" => "0358511020493189",
					
					"workerman_id" => "7f0000010fa300000028" ,
					"x" => 127.01256030186,
					"y" => 42.00820186311,
					);
	$data10 = Array( 
					"company" => "沈阳航空航天大学" ,
					"route_num" => 11 ,
					"plate_num" => "辽A6387A" ,
					"longitude" => 12745.1307,
					"latitude" => 423.25709999,
					"imei" => "0358511020493171",
					
					"workerman_id" => "7f0000010fa300000029" ,
					"x" => 127.01256030186,
					"y" => 42.00820186311,
					);
	$data11 = Array( 
					"company" => "沈阳航空航天大学" ,
					"route_num" => 11 ,
					"plate_num" => "辽A6387A" ,
					"longitude" => 12745.1307,
					"latitude" => 423.25709999,
					"imei" => "0358911020122939",
					
					"workerman_id" => "7f0000010fa300000030" ,
					"x" => 127.01256030186,
					"y" => 42.00820186311,
					);
	$data12 = Array( 
					"company" => "沈阳航空航天大学" ,
					"route_num" => 11 ,
					"plate_num" => "辽A6387A" ,
					"longitude" => 12745.1307,
					"latitude" => 423.25709999,
					"imei" => "0358511020493429",
					
					"workerman_id" => "7f0000010fa300000031" ,
					"x" => 127.01256030186,
					"y" => 42.00820186311,
					);
	$data13 = Array( 
					"company" => "沈阳航空航天大学" ,
					"route_num" => 11 ,
					"plate_num" => "辽A6387A" ,
					"longitude" => 12745.1307,
					"latitude" => 423.25709999,
					"imei" => "0358511020493239",
					
					"workerman_id" => "7f0000010fa300000032",
					"x" => 127.01256030186,
					"y" => 42.00820186311,					
					);
	$data14 = Array( 
					"company" => "沈阳航空航天大学" ,
					"route_num" => 11 ,
					"plate_num" => "辽A6387A" ,
					"longitude" => 12745.1307,
					"latitude" => 423.25709999,
					"imei" => "0358511020493254",
					
					"workerman_id" => "7f0000010fa300000033" ,
					"x" => 127.01256030186,
					"y" => 42.00820186311,
					);
	$data15 = Array( 
					"company" => "沈阳航空航天大学" ,
					"route_num" => 11 ,
					"plate_num" => "辽A6387A" ,
					"longitude" => 12745.1307,
					"latitude" => 423.25709999,
					"imei" => "0123456789012345",
					
					"workerman_id" => "7f0000010fa300000034" ,
					"x" => 127.01256030186,
					"y" => 42.00820186311,
					);
	$data17 = Array( 
					"company" => "沈阳航空航天大学" ,
					"route_num" => 11 ,
					"plate_num" => "辽A6387A" ,
					"longitude" => 12745.1307,
					"latitude" => 423.25709999,
					"imei" => "0358511020493221",
					
					"workerman_id" => "7f0000010fa300000035" ,
					"x" => 127.01256030186,
					"y" => 42.00820186311,
					);
	$data18 = Array( 
					"company" => "沈阳航空航天大学" ,
					"route_num" => 11 ,
					"plate_num" => "辽A6387A" ,
					"longitude" => 12745.1307,
					"latitude" => 423.25709999,
					"imei" => "1234567890123456",
					
					"workerman_id" => "7f0000010fa300000036" ,
					"x" => 127.01256030186,
					"y" => 42.00820186311,
					);
	$data19 = Array( 
					"company" => "沈阳航空航天大学" ,
					"route_num" => 11 ,
					"plate_num" => "辽A6387A" ,
					"longitude" => 12745.1307,
					"latitude" => 423.25709999,
					"imei" => "0355784011560745",
					
					"workerman_id" => "7f0000010fa300000037" ,
					"x" => 127.01256030186,
					"y" => 42.00820186311,
					);
	$data20 = Array( 
					"company" => "沈阳航空航天大学" ,
					"route_num" => 11 ,
					"plate_num" => "辽A6387A" ,
					"longitude" => 12745.1307,
					"latitude" => 423.25709999,
					"imei" => "0355784011561420",
					
					"workerman_id" => "7f0000010fa300000038" ,
					"x" => 127.01256030186,
					"y" => 42.00820186311,
					);
	$data21 = Array( 
					"company" => "沈阳航空航天大学" ,
					"route_num" => 11 ,
					"plate_num" => "辽A6387A" ,
					"longitude" => 12745.1307,
					"latitude" => 423.25709999,
					"imei" => "03557840115614",
					
					"workerman_id" => "7f0000010fa300000039" ,
					"x" => 127.01256030186,
					"y" => 42.00820186311,
					);
	$data22 = Array( 
					"company" => "沈阳航空航天大学" ,
					"route_num" => 11 ,
					"plate_num" => "辽A6387A" ,
					"longitude" => 12745.1307,
					"latitude" => 423.25709999,
					"imei" => "0102030405060708",
					"workerman_id" => "7f0000010fa300000040" ,
					"x" => 127.01256030186,
					"y" => 42.00820186311,
					);
	// 向memcache中插入数据
	$mem->set("bus_list", $bus_list, 0);
	$mem->set($data1["imei"], json_encode($data1));
	$mem->set($data2["imei"], json_encode($data2));
	$mem->set($data3["imei"], json_encode($data3));
	$mem->set($data4["imei"], json_encode($data4));
	$mem->set($data5["imei"], json_encode($data5));
	$mem->set($data6["imei"], json_encode($data6));
	$mem->set($data7["imei"], json_encode($data7));
	$mem->set($data8["imei"], json_encode($data8));
	$mem->set($data9["imei"], json_encode($data9));
	$mem->set($data10["imei"], json_encode($data10));
	$mem->set($data11["imei"], json_encode($data11));
	$mem->set($data12["imei"], json_encode($data12));
	$mem->set($data13["imei"], json_encode($data13));
	$mem->set($data14["imei"], json_encode($data14));
	$mem->set($data15["imei"], json_encode($data15));
	
	$mem->set($data17["imei"], json_encode($data17));
	$mem->set($data18["imei"], json_encode($data18));
	$mem->set($data19["imei"], json_encode($data19));
	$mem->set($data20["imei"], json_encode($data20));
	$mem->set($data21["imei"], json_encode($data21));
	$mem->set($data22["imei"], json_encode($data22));
	
	
					
     
	// 从memcache中获取车辆的的imei列表返回的是数组形式
    print_r($mem->get("bus_list"));
    echo '<br>';
	// 从memcache中获取具体车辆的信息，返回的json格式，在这里读取的时候把json格式转换成了数据进行处理
    print_r(json_decode($mem->get("0358911020137762"), true));
    echo '<br>';
 
    print_r(json_decode($mem->get("0358911020148140"), true));
    echo '<br>';
 
    print_r(json_decode($mem->get("0358911020137754"), true));
    echo '<br>';
 
    print_r(json_decode($mem->get("0358911020137739"), true));
    echo '<br>';
	
	print_r(json_decode($mem->get("0358911020137747"), true));
    echo '<br>';
 
	print_r(json_decode($mem->get("0358911020137721"), true));
    echo '<br>';
	print_r(json_decode($mem->get("0358511020493213"), true));
    echo '<br>';
	print_r(json_decode($mem->get("0865067022454725"), true));
    echo '<br>';
	print_r(json_decode($mem->get("0358511020493759"), true));
    echo '<br>';
	print_r(json_decode($mem->get("0358511020493189"), true));
    echo '<br>';
	print_r(json_decode($mem->get("0358511020493171"), true));
    echo '<br>';
	print_r(json_decode($mem->get("0358911020122939"), true));
    echo '<br>';
	print_r(json_decode($mem->get("0358511020493429"), true));
    echo '<br>';
	print_r(json_decode($mem->get("0355784011561420"), true));
    echo '<br>';
	print_r(json_decode($mem->get("03557840115614"), true));
    echo '<br>';
    print_r(json_decode($mem->get("0102030405060708"), true));
    echo '<br>';
?>